package com.juku2024.juku.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.juku2024.juku.R
import com.juku2024.juku.model.PlayInfoResponse
import com.juku2024.juku.tools.AppUtils
import java.util.*

class DownloadSourceAdapter(data: ArrayList<PlayInfoResponse>) :
    BaseQuickAdapter<PlayInfoResponse, BaseViewHolder>(R.layout.item_download_source, data) {

    override fun convert(holder: BaseViewHolder, item: PlayInfoResponse) {
        holder.setText(R.id.tv_download_source, AppUtils.getSourceName(item.id))
        val bgResId = if (item.isSelected) {
            R.drawable.shape_solid_f7f7f7_stroke_w6_4488f0_r15
        } else {
            R.drawable.shape_solid_f7f7f7_r15_stroke_w6_c4a4a4a
        }
        holder.itemView.setBackgroundResource(bgResId)

        holder.setGone(R.id.source_downloadStatus, !item.hasDownloads)
    }

}